/** 
* @file pmu.h
* Physical Memory Unit (header declaration).
*
* Copyrights 2010 Michal Saman, m.saman@designplus.cz.
* This source code is release under the Apache License 2.0.
* http://www.apache.org/licenses/LICENSE-2.0
*/

#ifndef _PMU_H
#define _PMU_H

#include <stdint.h>

/** 8 blocks are defined per byte, 1 block = 1 bit in our memory map. */
#define PMU_BLOCKS_PER_BYTE 8

/** Default size of one memory block. */
#define PMU_BLOCK_SIZE 4096

/** Default block aligment. */
#define PMU_BLOCK_ALIGN 4096

/** Data structure of memory region, output from BIOS function: BiosGetMemoryMap */
struct memory_region {
	int32_t		startLo;
	uint32_t	startHi;
	uint32_t	sizeLo;
	uint32_t	sizeHi;
	uint32_t	type;
	uint32_t	acpi30;
};

/** String desctiptions for memory_region.type */
static char *str_memory_types[] = {
	"Available",
	"Reserved",
	"ACPI Reclaim",
	"ACPI NVS Memory"
};

/** Physical address definition */
typedef uint32_t physical_addr;

extern void pmu_init(physical_addr bitmap);
extern void pmu_init_region(physical_addr base, size_t size);
extern void pmu_deinit_region(physical_addr base, size_t size);
extern void *pmu_alloc_block();
extern void pmu_free_block(void* p);
extern void *pmu_alloc_blocks(size_t size);
extern void pmu_free_blocks(void* p, size_t size);
extern size_t pmu_get_memory_size();
extern size_t pmu_get_memory_map_size();
extern uint32_t pmu_get_use_block_count();
extern uint32_t pmu_get_free_block_count();
extern uint32_t pmu_get_block_count();
extern uint32_t pmu_get_block_size();
extern void pmu_detect_phys_memory_size();
//extern bool pmu_is_paging();
//extern physical_addr pmu_get_PDBR();

#endif
